var http = require('http')
var fs = require('fs')

http.get("https://pic.qqtn.com/up/2019-8/2019080116484576144.jpg", function(req,res){  // path为网络图片地址
  var imgData = '';
  req.setEncoding('binary');
  req.on('data',function(chunk){
    imgData += chunk
  })
  req.on('end',function(){
    fs.writeFile('./localDownload/logo.png',imgData,'binary',function(err){  //path为本地路径例如public/logo.png
      if(err){console.log('保存出错！')}else{
        console.log('保存成功!')
      }
    })
  })
})